package com.example.ebeanbase.utils;

import com.example.ebeanbase.common.base.BaseController;
import com.example.ebeanbase.entity.User;

/**
 * 验证用户token工具类
 *
 * @author huangke
 */
public class CheckTokenUtil {

    /**
     * 验证token是否正确
     *
     * @param token
     * @return
     */
    public static String check(String token, String roleType) {

        String status = "0";

        if (StringUtil.isNotBlank(token)&&StringUtil.isNotBlank(roleType)) {

            BaseController baseController = new BaseController();
            User userInfo = baseController.getUserInfo(token,roleType);
            if (userInfo != null) {
                //这里本来应该加入用户锁，项目初期先省略

                status = "1";

            }
        }

        return status;
    }

}
